#-*- coding: utf8 -*-
from tutor.scripts import *
from tutor.plugins.sympy import *

# Entradas
coords = [Half, -Half,
          One, One, One, -One,
          Three / 2, -Three / 2,
          Two, -Two,
          Three, -Three,
          Four, -Four ]

with display_block('Variáveis'):
    n_iter = 0
    while True:
        n_iter += 1
        shuffle(coords)
        rx, ry, sx, sy = coords[:4]
        pt1 = (rx, ry)
        pt2 = (sx, sy)
        pt3 = (rx + sx, ry + sy)

        RR = rx ** 2 + ry ** 2
        SS = sx ** 2 + sy ** 2
        RS = rx * sx + ry * sy
        jacob = abs(rx * sy - ry * sx)
        if jacob == 0 or rx == sx:
            continue
        for x in [RR, SS, RS, jacob]:
            n, d = x.as_numer_denom()
            if n > 100 or d > 50:
                continue

        jacobiano = (RR + SS) / 3 + RS / 2
        correta = jacob * jacobiano
        jdist = Two / 3
        distanciaErrada = jacob * jdist
        ans = set([correta, distanciaErrada, jacobiano, jdist])
        
        distratores = set()
        while len(distratores) < 4:
            n = oneof(*ans)
            number = n * randint(1, 5) / randint(1, 5)
            if number not in ans:
                distratores.add(number)
        dis_1, dis_2, dis_3, dis_4 = distratores

        do_break = True
        for x in ans.union(distratores):
            n, d = x.as_numer_denom()
            if (n > 100) or (d > 50):
                do_break = False

        if do_break and len(ans.union(distratores)) == 8:
            break

